// type Point = {
//     x: number;
//     y: number;
// };
//
// function distance(point1: Point, point2: Point): number {
//     const dx = point2.x - point1.x;
//     const dy = point2.y - point1.y;
//     return Math.sqrt(dx ** 2 + dy ** 2);
// }
//
// const p1: Point = { x: 0, y: 0 };
// const p2: Point = { x: 6, y: 8 };
// const d = distance(p1, p2);
// console.log(d);
//10

// type ValueType<T> = T extends boolean | number ? T : string;
//
// const val1: ValueType<boolean> = true;
// const val2: ValueType<number> = 888;
// const val3: ValueType<string> = "I love TypeScript~";
// console.log(val1)
// console.log(val2)
// console.log(val3)
// true
// 888
// I love TypeScript~


type Customer = {
    username: string;
    userId: number;
    email: string;
};

type CustomerKeys = keyof Customer;

// 创建一个customer对象
const customer: Customer = {
    username: "ShirDon",
    userId: 18,
    email: "shirdon@example.com"
};

// 访问和使用customer对象的键
const keys: CustomerKeys[] = ["username", "userId", "email"];
keys.forEach((key: CustomerKeys) => {
    console.log(`Key: ${key}, Value: ${customer[key]}`);
});
// Key: username, Value: ShirDon
// Key: userId, Value: 18
// Key: email, Value: shirdon@example.com